package com.example.qxfw.nyqx.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.example.qxfw.common.entity.ny.CropGrowdateIndexlib;
import com.example.qxfw.nyqx.mapper.CropGrowdateIndexlibMapper;
import com.example.qxfw.nyqx.service.CropGrowdateIndexlibService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class CropGrowdateIndexlibServiceImpl implements CropGrowdateIndexlibService {

    @Autowired
    private CropGrowdateIndexlibMapper cropGrowdateIndexlibMapper;

    @Override
    public List<String> getCropName() {
        List<String> list = cropGrowdateIndexlibMapper.selectCropName();
        List<String> names = new ArrayList<>();
        for (String s : list) {
            String name = s.trim();
            names.add(name);
        }
        return names;
    }

    @Override
    public List<String> getCropName1(String indexId) {
        return cropGrowdateIndexlibMapper.selectCropName1(indexId);
    }

    @Override
    public List<String> getType(String cropName) {
        return cropGrowdateIndexlibMapper.selectType(cropName);
    }

    @Override
    public List<String> getType1() {
        return cropGrowdateIndexlibMapper.selectType1();
    }

    @Override
    public List<String> getGrowDateName(String cropName) {
        List<String> nameList = cropGrowdateIndexlibMapper.selectGrowDateName(cropName);
        return nameList.stream().distinct().collect(Collectors.toList());
    }

    @Override
    public List<CropGrowdateIndexlib> getList(String cropName) {
        return cropGrowdateIndexlibMapper.selectList(cropName);
    }

    @Override
    public List<CropGrowdateIndexlib> getList1(String time1, String time2) {
        return cropGrowdateIndexlibMapper.selectList1(time1,time2);
    }

    @Override
    public List<CropGrowdateIndexlib> getList2(String time1, String time2) {
        return cropGrowdateIndexlibMapper.selectList2(time1, time2);
    }

    @Override
    public List<CropGrowdateIndexlib> getList3(String date1, String date2, String date3) {
        return cropGrowdateIndexlibMapper.selectList3(date1, date2, date3);
    }

    @Override
    public List<CropGrowdateIndexlib> getList4(String month) {
        return cropGrowdateIndexlibMapper.selectList4(month);
    }

    @Override
    public List<CropGrowdateIndexlib> getList5(String month, String cropName) {
        return cropGrowdateIndexlibMapper.selectList5(month,cropName);
    }

    @Override
    public List<CropGrowdateIndexlib> getList6(String month, String cropName, String type) {
        return cropGrowdateIndexlibMapper.selectList6(month,cropName,type);
    }


    @Override
    public Integer update(CropGrowdateIndexlib cropGrowdateIndexlib) {
        return cropGrowdateIndexlibMapper.update(cropGrowdateIndexlib, Wrappers.<CropGrowdateIndexlib>lambdaUpdate());
    }

    @Override
    public List<String> getJoinStation(String indexId) {
        return cropGrowdateIndexlibMapper.getJoinStation(indexId);
    }

    @Override
    public Integer update1(CropGrowdateIndexlib cropGrowdateIndexlib) {
        return cropGrowdateIndexlibMapper.update(cropGrowdateIndexlib);
    }
}
